package model

import (
	"gorm.io/plugin/soft_delete"
	"time"
)

type BaseModel struct {
	ID        uint64                `gorm:"primarykey;comment:主键"`
	CreateAt  time.Time             `gorm:"column:create_time;autoCreateTime;comment:创建时间"`
	UpdateAt  time.Time             `gorm:"column:update_time;autoUpdateTime;comment:更新时间"`
	IsDeleted soft_delete.DeletedAt `gorm:"type:int(1);not null;softDelete:flag,DeletedAtField:DeletedAt;default:0;comment:0未删除1删除"`
	Status    int32                 `gorm:"type:int(1);not null;default:1;comment:0未发布1发布"`
	// 忽略该字段，- 表示无读写，-:migration 表示无迁移权限，-:all 表示无读写迁移权限
	//Children any `gorm:"-" json:"children"`
}

// 用户收货地址
type UserAddress struct {
	BaseModel
	UserId      uint64 `gorm:"type:bigint;index;not null;comment:用户ID"`
	Province    string `gorm:"type:varchar(20);default:'';not null;comment:省份"`
	City        string `gorm:"type:varchar(20);default:'';not null;comment:城市"`
	District    string `gorm:"type:varchar(100);default:'';not null;comment:地区"`
	Address     string `gorm:"type:varchar(200);default:'';not null;comment:详细地址"`
	Username    string `gorm:"type:varchar(100);default:'';not null;comment:收货人"`
	Mobile      string `gorm:"type:varchar(11);default:'';not null;comment:收货人手机"`
	DefaultFlag bool   `gorm:"not null;default:0;comment:是否默认地址"`
}

func (c *UserAddress) TableName() string {
	return "ksd_user_address"
}

// 用户收藏表
type UserFav struct {
	BaseModel
	UserId  uint64 `gorm:"type:bigint;index:idx_fav_user_goods,unique;not null;comment:用户ID"`
	GoodsId uint64 `gorm:"type:bigint;index:idx_fav_user_goods,unique;not null;comment:商品ID"`
}

func (c *UserFav) TableName() string {
	return "ksd_user_fav"
}
